package com.sike.netty.jinjie.channelhandler.custom;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CustomChannelHandlerServer {
    public static void main(String[] args) {
        new ServerBootstrap()
                .group(new NioEventLoopGroup(),new NioEventLoopGroup())
                .channel(NioServerSocketChannel.class)
                .childHandler(new ChannelInitializer<NioSocketChannel>() {
                    @Override
                    protected void initChannel(NioSocketChannel ch) throws Exception {
                        ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO));
                        ch.pipeline().addLast(new StringDecoder());
//                      ch.pipeline().addLast(new CustomChannelHandler01());
//                      ch.pipeline().addLast(new CustomChannelHandler02());
//                      ch.pipeline().addLast(new CustomChannelHandler03());
//                      ch.pipeline().addLast(new CustomChannelHandler04());
                        ch.pipeline().addLast(new CustomChannelHandler05());
                    }
                }).bind(8081);
    }
}
